<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block data-th-replace="/adminlte/base::base-head"></th:block>
    <link rel="stylesheet" href="/plugins/datatables-bs4/css/dataTables.bootstrap4.css">
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="modal fade" id="dialog-role-add">
    <div class="modal-dialog">
        <div class="modal-content"
             style="border-radius: 5px; margin-top: 10%; border-radius: 5px;">
            <div class="modal-header">
                <h4 class="modal-title">新增角色</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form role="form" action="/roles" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label><span class="text-red">*</span> 角色名称</label>
						<input type="text" class="form-control" name="name" placeholder="角色名称" autofocus="autofocus" required="required">
                    </div>
                    <div class="form-group">
                        <label><span class="text-red">*</span> 角色排序</label>
						<input type="text" class="form-control" placeholder="角色排序" name="sort" required="required">
                    </div>
                    <div class="form-group">
                        <label>角色备注</label>
                        <textarea class="form-control" rows="5" placeholder="角色备注 ..." name="remark"></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default float-left" data-dismiss="modal" style="width: 100px" type="button">取消</button>
                    <button class="btn btn-success float-right" style="width: 100px" type="submit">确定</button>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="wrapper">
    <th:block data-th-replace="/adminlte/base::base-navbar"></th:block>
    <th:block data-th-replace="/adminlte/base::base-main-sidebar"></th:block>
    <div class="content-wrapper">
        <th:block data-th-replace="/adminlte/base::base-content-header"></th:block>
        <section class="content">
            <div class="container-fluid">
                <div class="card">
                    <div class="card-header">
                        <div class="row mt-2">
                            <button class="btn btn-app" data-dialog="show" data-url="#dialog-role-add">
                                <i class="fas fa-plus text-blue"></i> 新增角色
                            </button>
                        </div>
                    </div>

                    <div class="card-body table-responsive">
                        <div class="table-responsive">
                            <table id="role-table" class="table table-bordered table-hover" data-url="/roles/">
                                <colgroup>
                                    <col width="100"/>
                                    <col width="200"/>
                                    <col/>
                                    <col width="150"/>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>排序</th>
                                    <th>名称</th>
                                    <th>备注</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
									<tr data-th-each="role : ${roleList}" th:data-key="${role.id}">
										<td data-th-utext="${role.sort}" data-col-name="sort"
											contenteditable="true">排序
										</td>
										<td data-th-utext="${role.name}" data-col-name="name"
											contenteditable="true">角色名称
										</td>
										<td data-th-utext="${role.remark}" data-col-name="remark"
											contenteditable="true">角色描述
										</td>
										<td class="td-manage">
											<a title="查看用户"
											   th:href="${'/admin/user?roleId='+role.id}"
											   style="margin-left: 10px;"> <i
													class="fas fa-users text-blue"></i>
											</a>
											<a title="查看权限"
											   th:href="${'/admin/permission/power?roleId='+role.id}"
											   style="margin-left: 10px;"> <i
													class="fas fa-search text-blue"></i>
											</a>
											<a th:if="${role.id!=1 && role.id!=2}" title="删除角色"
											   data-dialog="confirm"
											   data-url="/roles/"
											   data-method="delete"
											   th:data-path="${role.id}"
											   data-dialog-t-msg="您确定要删除当前角色吗？" style="margin-left: 10px;">
												<i class="fas fa-trash text-blue"></i>
											</a>
										</td>
									</tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <th:block data-th-replace="/adminlte/base::base-footer"></th:block>
    <th:block data-th-replace="/adminlte/base::base-control-sidebar"></th:block>
</div>
<script src="/plugins/datatables/jquery.dataTables.js"></script>
<script src="/plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
<script src="/kaibes/js/table-data.js"></script>
<script src="/kaibes/js/table-update.js"></script>
<script type="text/javascript">
    dataTable(0, [1, 2, 3]);
</script>
</body>
</html>